import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class ChoiceCommon {
  static Container singleChoice(String title, List<Widget> widgets) {
    return Container(
        margin: EdgeInsets.symmetric(horizontal: 20.w),
        decoration: BoxDecoration(
            border: Border(bottom: BorderSide(color: Colors.grey))),
        child: Row(
          children: [
            Container(
              child: Text(
                title,
                textAlign: TextAlign.start,
                style: TextStyle(fontSize: 14.sp, color: Colors.green[500]),
              ),
              width: 70.w,
            ),
            Expanded(
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: widgets,
                ),
                flex: 9),
          ],
        ));
  }

  static Container multipleChoice(String title, List<Widget> widgets) {
    return Container(
        margin: EdgeInsets.symmetric(horizontal: 20.w),
        decoration: BoxDecoration(
            border: Border(bottom: BorderSide(color: Colors.grey))),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          children: [
            Container(
              child: Text(
                title,
                textAlign: TextAlign.start,
                style: TextStyle(fontSize: 14.sp, color: Colors.green[500]),
              ),
              width: 70.w,
            ),
            Expanded(
                child: Container(
                  child: Wrap(
                    children: widgets,
                  ),
                ),
                flex: 9),
          ],
        ));
  }

  static Widget buildMultipleRadio(
      dynamic value, String title, List<String> chocis, Function callBack) {
    return Container(
        child: Row(
      mainAxisSize: MainAxisSize.min,
      mainAxisAlignment: MainAxisAlignment.start,
      children: [
        Checkbox(
          materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
          value: chocis.contains(value),
          onChanged: (change) {
            callBack(change, value, chocis);
          },
          activeColor: Colors.green[500],
          checkColor: Colors.white,
        ),
        Text(
          title,
          style: TextStyle(fontSize: 14.sp, color: Colors.green[500]),
        ),
      ],
    ));
  }

  static Row buildRadio(
      dynamic value, String title, dynamic groupValue, Function callBack) {
    return Row(
      mainAxisSize: MainAxisSize.min,
      children: [
        Radio<dynamic>(
          materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
          value: value,
          groupValue: groupValue,
          activeColor: Colors.green[500],
          onChanged: (value) {
            callBack(value);
          },
        ),
        Text(
          title,
          style: TextStyle(fontSize: 14.sp, color: Colors.green[500]),
        ),
      ],
    );
  }
}
